]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
quickSettings: Update bind constraint offset on idle
authorJonas Ådahl <jadahl@gmail.com>
Wed, 7 Sep 2022 21:17:22 +0000 (23:17 +0200)
committerMarge Bot <marge-bot@gnome.org>
Sat, 17 Sep 2022 18:09:57 +0000 (18:09 +0000)
Use Meta.LaterType.BEFORE_REDRAW to queue setting the bind constraint
offset in an idle callback. This is needed since the signals that
trigger updating the offset may be emitted during allocation, at which
point queuing new relayouts isn't ideal, since it could result in
relayout cycles. In this case, we really do want to relayout as a side
effect of another actors allocation, so make this explicit.

This fixes a few warnings such as:

The actor '<unnamed>[<StBoxLayout>:0x3138d70]' is currently inside an
allocation cycle; calling clutter_actor_queue_relayout() is not recommended

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2476>

js/ui/quickSettings.js

index 822893b782fbef5fc341ba2b41413338dbcf27dc..7a31d561d41ec601217391415302765065d8ed8a 100644 (file)
@@ -1,5 +1,5 @@
 /* exported QuickToggle, QuickMenuToggle, QuickSlider, QuickSettingsMenu, SystemIndicator */
-const {Atk, Clutter, Gio, GLib, GObject, Graphene, Pango, St} = imports.gi;
+const {Atk, Clutter, Gio, GLib, GObject, Graphene, Meta, Pango, St} = imports.gi;
 
 const Main = imports.ui.main;
 const PopupMenu = imports.ui.popupMenu;
@@ -626,9 +626,12 @@ var QuickSettingsMenu = class extends PopupMenu.PopupMenu {
 
         // Pick up additional spacing from any intermediate actors
         const updateOffset = () => {
-            const offset = this._grid.apply_relative_transform_to_point(
-                this._boxPointer, new Graphene.Point3D());
-            yConstraint.offset = offset.y;
+            Meta.later_add(Meta.LaterType.BEFORE_REDRAW, () => {
+                const offset = this._grid.apply_relative_transform_to_point(
+                    this._boxPointer, new Graphene.Point3D());
+                yConstraint.offset = offset.y;
+                return GLib.SOURCE_REMOVE;
+            });
         };
         this._grid.connect('notify::y', updateOffset);
         this.box.connect('notify::y', updateOffset);